home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / tpapi.exe / EXAMPLES / CPASS.PAS < prev    next >
Pascal/Delphi Source File  |  1994-01-14  |  3KB  |  106 lines

  1. {***************************************************************************}
  2. {** Program : CPASS                                                       **}
  3. {***************************************************************************}
  4. {** Version : 1.0             ** Started :           ** Ended :   /  /    **}
  5. {***************************************************************************}
  6. {******************************** Description ******************************}
  7. {***************************************************************************}
  8. {** Program which will allow a user to change their password from the     **}
  9. {** command line.                                                         **}
  10. {**                                                                       **}
  11. {**                                                                       **}
  12. {**                                                                       **}
  13. {***************************************************************************}
  14. {******************************** Information ******************************}
  15. {***************************************************************************}
  16. {** USAGE : CPASS oldpassword newpassword                                 **}
  17. {**                                                                       **}
  18. {** This program does not do much error checking.  It is meant only as a  **}
  19. {** guide to using TPAPI.                                                 **}
  20. {**                                                                       **}
  21. {***************************************************************************}
  22.  
  23. program CPASS;
  24.  
  25. USES
  26.  
  27.   NWVAR,
  28.   NWERROR,
  29.   NWBINDRY,
  30.   NWMISC;
  31.  
  32. CONST
  33.  
  34.   ProgramName = 'CPASS.EXE';
  35.   Version     = '1.0';
  36.   Description = 'Allows a user to change their password';
  37.  
  38. VAR
  39.  
  40.   BinderyServices : pBinderyOBJ;
  41.   MiscFunc        : pMiscFuncOBJ;
  42.   OldPassword,
  43.   NewPassword     : TPassword;
  44.  
  45. procedure Initialise;
  46.  
  47. BEGIN
  48.  
  49.   BinderyServices := new (pBinderyOBJ, Init (true));
  50.   MiscFunc := new (pMiscFuncOBJ, Init (true));
  51.   IF PARAMCOUNT < 2 THEN
  52.     BEGIN
  53.  
  54.       WRITELN;
  55.       WRITELN ('Program : ', ProgramName);
  56.       WRITELN ('Version : ', Version);
  57.       WRITELN ('Description : ', Description);
  58.       WRITELN;
  59.       WRITELN;
  60.       WRITELN ('USAGE : ');
  61.       WRITELN;
  62.       WRITELN ('CPASS oldpassword newpassword');
  63.       WRITELN;
  64.       HALT (1);
  65.  
  66.     END;
  67.  
  68.   OldPassword := BinderyServices^.UppercaseNW (PARAMSTR (1) );
  69.   NewPassword := BinderyServices^.UppercaseNW (PARAMSTR (2) );
  70.  
  71. END; {procedure Initialise}
  72.  
  73. {******}
  74.  
  75. procedure ChangePassword;
  76.  
  77. VAR
  78.  
  79.   NetError : WORD;
  80.   ObjectName : TObjectName;
  81.   ObjectType : OT_BinderyType;
  82.   ObjectID   : OT_BinderyID;
  83.  
  84. BEGIN
  85.  
  86.   WITH MiscFunc^ DO
  87.     NetError := GetObjectNameID (GetDefaultFileServerName, ObjectName, ObjectType, ObjectID);
  88.   NetError := BinderyServices^.ChangeBinderyObjectPassword (ObjectName, ObjectType,
  89.               OldPassword, NewPassword);
  90.  
  91.   WRITELN (GetBinderyServicesError (NetError) );
  92.  
  93. END; {procedure ChangePassword}
  94.  
  95. {******}
  96.  
  97. BEGIN
  98.  
  99.   Initialise;
  100.   ChangePassword;
  101.   DISPOSE (BinderyServices, Done);
  102.   DISPOSE (MiscFunc, Done);
  103.  
  104. END.
  105.  
  106.